export default function useForm(form) {
    const formColumns = [
        {
            colProps: {
                span: 24,
            },
            label: '上级菜单',
            prop: 'parentId',
        },
        {
            colProps: {
                span: 24,
            },
            label: '菜单类型',
            options: [
                {
                    label: '目录',
                    value: 'M',
                },
                {
                    label: '菜单',
                    value: 'C',
                },
                {
                    label: '按钮',
                    value: 'F',
                },

            ],
            prop: 'menuType',
            valueType: 'radio',
        },
        {
            colProps: {
                span: 24,
            },
            hideInForm: computed(() => form.value.menuType === 'F'),
            label: '菜单图标',
            prop: 'icon',
        },
        {
            colProps: {
                span: 12,
            },
            fieldProps: {
                max: 11,
            },
            label: '菜单名称',
            prop: 'menuName',
        },
        {
            colProps: {
                span: 12,
            },
            fieldProps: {
                max: 999,
                min: 1,
            },
            label: '显示排序',
            prop: 'orderNum',
            valueType: 'input-number',

        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType === 'F'),
            label: '是否外链',
            options: [
                {
                    label: '是',
                    value: '0',
                },
                {
                    label: '否',
                    value: '1',
                },
            ],
            prop: 'isFrame',
            tooltip: '选择是外链则路由地址需要以`http(s)://`开头',
            valueType: 'radio',
        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType === 'F'),
            label: '路由地址',
            prop: 'path',
            tooltip: '访问的路由地址，如：`user`，如外网地址需内链访问则以`http(s)://`开头',
        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType === 'F'),
            label: '组件路径',
            prop: 'component',
            tooltip: '访问的组件路径，如：`system/user/index`，默认在`views`目录下',
        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType === 'F'),
            label: '组件名称',
            prop: 'name',
        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType === 'F'),
            label: '页面重定向',
            prop: 'redirect',
        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType === 'F'),
            label: '父级高亮路由',
            prop: 'activeMenu',
        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType === 'M'),
            label: '权限字符',
            prop: 'perms',
            tooltip: '控制器中定义的权限字符，如：@PreAuthorize(`@ss.hasPermi(\'system:user:list\')`)',
        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType !== 'C'),
            label: '路由参数',
            prop: 'query',
            tooltip: '访问路由的默认传递参数，如：`{"id": 1, "name": "ry"}`',
        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType !== 'C'),
            label: '是否缓存',
            options: [
                {
                    label: '缓存',
                    value: '0',
                },
                {
                    label: '不缓存',
                    value: '1',
                },
            ],
            prop: 'isCache',
            tooltip: '选择是则会被`keep-alive`缓存，需要匹配组件的`name`和地址保持一致',
            valueType: 'radio',
        },
        {
            colProps: {
                span: 12,
            },
            hideInForm: computed(() => form.value.menuType === 'F'),
            label: '显示状态',
            options: [
                {
                    label: '显示',
                    value: '0',
                },
                {
                    label: '隐藏',
                    value: '1',
                },
            ],
            prop: 'visible',
            tooltip: '选择隐藏则路由将不会出现在侧边栏，但仍然可以访问',
            valueType: 'radio',
        },
        {
            colProps: {
                span: 12,
            },
            label: '菜单状态',
            options: [
                {
                    label: '正常',
                    value: '0',
                },
                {
                    label: '停用',
                    value: '1',
                },
            ],
            prop: 'status',
            tooltip: '选择停用则路由将不会出现在侧边栏，也不能被访问',
            valueType: 'radio',
        },
    ]
    const rules = {
        menuName: [{ message: '菜单名称不能为空', required: true, trigger: 'blur' }],
        orderNum: [{ message: '菜单顺序不能为空', required: true, trigger: 'blur' }],
        path: [{ message: '路由地址不能为空', required: true, trigger: 'blur' }],
    }
    return { formColumns, rules }
}
